package com.ecp.commons.bean;

import java.util.Date;

import com.ecp.commons.annotation.VariantType;
import com.ecp.commons.serialization.GenericBean;
import com.ecp.commons.serialization.Variant;

public class Advertising extends GenericBean {

	public static final int ALIGN_CENTER = 2;
	public static final int ALIGN_DEFAULT = 0;
	public static final int ALIGN_LEFT = 1;
	public static final int ALIGN_RIGHT = 3;
	public static final int DEFAULTFLAG_AUTOSET = 0; // 时间段设定
	public static final int DEFAULTFLAG_MANSET = 1; // 手工设定
	public static final int IFSHOW_NO = 0;
	public static final int IFSHOW_YES = 1;

	@Override
	public void defineVariantSet() {
		this.entity = "cms_advertising";
		map.put("advPlaceId", new Variant().setType(VariantType.INTEGER));
		map.put("advTypeId", new Variant().setType(VariantType.INTEGER));
		map.put("align", new Variant().setType(VariantType.INTEGER));
		map.put("background", new Variant().setLength(0));
		map.put("beginTime", new Variant().setType(VariantType.DATETIME));
		map.put("clickUrl", new Variant().setLength(0));
		map.put("columnId", new Variant().setType(VariantType.INTEGER));
		map.put("content", new Variant().setLength(0));
		map.put("createTime", new Variant().setType(VariantType.DATETIME));
		map.put("defaultFlag", new Variant().setType(VariantType.INTEGER));
		map.put("description", new Variant().setLength(0));
		map.put("endTime", new Variant().setType(VariantType.DATETIME));
		map.put("extendId", new Variant().setType(VariantType.INTEGER));
		map.put("height", new Variant().setType(VariantType.INTEGER));
		map.put("id", new Variant().setType(VariantType.INTEGER).setPk(true).setNullable(false));
		map.put("ifShow", new Variant().setType(VariantType.INTEGER));
		map.put("mId", new Variant().setType(VariantType.INTEGER));
		map.put("picsPath", new Variant().setLength(0));
		map.put("picUrl", new Variant().setLength(0));
		map.put("sortOrder", new Variant().setType(VariantType.INTEGER));
		map.put("tip", new Variant().setType(VariantType.STRING));
		map.put("title", new Variant().setLength(0));
		map.put("width", new Variant().setType(VariantType.INTEGER));
		map.put("requestType", new Variant().setType(VariantType.STRING));
		map.put("appType", new Variant().setType(VariantType.INTEGER));
	}

	@Override
	public void resetValues() {
		this.set("advPlaceId", "");
		this.set("advTypeId", "");
		this.set("align", "0");
		this.set("background", "");
		this.set("beginTime", "");
		this.set("clickUrl", "");
		this.set("columnId", "");
		this.set("content", "");
		this.set("createTime", "");
		this.set("defaultFlag", "");
		this.set("description", "");
		this.set("endTime", "");
		this.set("extendId", 0);
		this.set("height", 100);
		this.set("id", 0);
		this.set("ifShow", "");
		this.set("mId", 0);
		this.set("picsPath", "");
		this.set("picUrl", "");
		this.set("sortOrder", "");
		this.set("tip", "");
		this.set("title", "");
		this.set("width", 100);
		this.set("requestType", "");
		this.set("appType", "");
	}

	// 查询语句涉及当前时间，导致大量缓存。暂不适用缓存，优化后再说
	@Override
	public boolean needCached() {
		return false;
	}

	public int getAdvPlaceId() {
		return this.getInt("advPlaceId");
	}

	public int getAdvTypeId() {
		return this.getInt("advTypeId");
	}

	public int getAlign() {
		return this.getInt("align");
	}

	public String getBackground() {
		return this.getString("background");
	}

	public Date getBeginTime() {
		return this.getDate("beginTime");
	}

	public String getClickUrl() {
		return this.getString("clickUrl");
	}

	public int getColumnId() {
		return this.getInt("columnId");
	}

	public String getContent() {
		return this.getString("content");
	}

	public Date getCreateTime() {
		return this.getDate("createTime");
	}

	public int getDefaultFlag() {
		return this.getInt("defaultFlag");
	}

	public String getDescription() {
		return this.getString("description");
	}

	public Date getEndTime() {
		return this.getDate("endTime");
	}

	public int getExtendId() {
		return this.getInt("extendId");
	}

	public int getHeight() {
		return this.getInt("height");
	}

	public int getId() {
		return this.getInt("id");
	}

	public int getIfShow() {
		return this.getInt("ifShow");
	}

	public int getMId() {
		return this.getInt("mId");
	}

	public String getPicsPath() {
		return this.getString("picsPath");
	}

	public String getPicUrl() {
		return this.getString("picUrl");
	}

	public int getSortOrder() {
		return this.getInt("sortOrder");
	}

	public String getTip() {
		return this.getString("tip");
	}

	public String getTitle() {
		return this.getString("title");
	}

	public int getWidth() {
		return this.getInt("width");
	}

	public String getRequestType() {
		return this.getString("requestType");
	}

	public int getAppType() {
		return this.getInt("appType");
	}

	public void setAdvPlaceId(int advPlaceId) {
		this.set("advPlaceId", advPlaceId);
	}

	public void setAdvTypeId(int advTypeId) {
		this.set("advTypeId", advTypeId);
	}

	public void setAlign(int align) {
		this.set("align", align);
	}

	public void setBackground(String background) {
		this.set("background", background);
	}

	public void setBeginTime(Date beginTime) {
		this.set("beginTime", beginTime);
	}

	public void setClickUrl(String clickUrl) {
		this.set("clickUrl", clickUrl);
	}

	public void setColumnId(int columnId) {
		this.set("columnId", columnId);
	}

	public void setContent(String content) {
		this.set("content", content);
	}

	public void setCreateTime(Date createTime) {
		this.set("createTime", createTime);
	}

	public void setDefaultFlag(int defaultFlag) {
		this.set("defaultFlag", defaultFlag);
	}

	public void setDescription(String description) {
		this.set("description", description);
	}

	public void setEndTime(Date endTime) {
		this.set("endTime", endTime);
	}

	public void setExtendId(int extendId) {
		this.set("extendId", extendId);
	}

	public void setHeight(int height) {
		this.set("height", height);
	}

	public void setId(int id) {
		this.set("id", id);
	}

	public void setIfShow(int ifShow) {
		this.set("ifShow", ifShow);
	}

	public void setMId(int m_id) {
		this.set("mId", m_id);
	}

	public void setPicsPath(String picsPath) {
		this.set("picsPath", picsPath);
	}

	public void setPicUrl(String picUrl) {
		this.set("picUrl", picUrl);
	}

	public void setSortOrder(int sortOrder) {
		this.set("sortOrder", sortOrder);
	}

	public void setTip(String tip) {
		this.set("tip", tip);
	}

	public void setTitle(String title) {
		this.set("title", title);
	}

	public void setWidth(int width) {
		this.set("width", width);
	}

	public void setRequestType(String requestType) {
		this.set("requestType", requestType);
	}

	public void setAppType(int appType) {
		this.set("appType", appType);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + getId();
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Advertising other = (Advertising) obj;
		if (getId() != other.getId())
			return false;
		return true;
	}
}
